/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.gxuwz.byssxsys.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.gxuwz.byssxsys.model.*;
import com.gxuwz.byssxsys.dao.*;
import com.gxuwz.byssxsys.service.*;
import com.gxuwz.byssxsys.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class StuBaseInfoDao extends BaseHibernateDao<StuBaseInfo,java.lang.Integer>{

	public Class getEntityClass() {
		return StuBaseInfo.class;
	}
	
	public Page findPage(StuBaseInfoQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from StuBaseInfo t where 1=1 "
			  	+ "/~ and t.stuNo1 = {stuNo1} ~/"
			  	+ "/~ and t.stuName2 = {stuName2} ~/"
			  	+ "/~ and t.stuSex3 = {stuSex3} ~/"
			  	+ "/~ and t.stuZy4 = {stuZy4} ~/"
			  	+ "/~ and t.stuClasses5 = {stuClasses5} ~/"
			  	+ "/~ and t.stuXi6 = {stuXi6} ~/"
			  	+ "/~ and t.stuIdcard7 = {stuIdcard7} ~/"
			  	+ "/~ and t.stuMobilePhone8 = {stuMobilePhone8} ~/"
			  	+ "/~ and t.stuEmail9 = {stuEmail9} ~/"
			  	+ "/~ and t.stuSpeciality10 = {stuSpeciality10} ~/"
			  	+ "/~ and t.stuAwards11 = {stuAwards11} ~/"
			  	+ "/~ and t.stuPassword12 = {stuPassword12} ~/"
			  	+ "/~ and t.stuRemark13 = {stuRemark13} ~/"
			  	+ "/~ and t.stuStatue14 = {stuStatue14} ~/"
				+ "/~ order by [sortColumns] ~/";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from StuBaseInfo t where 1=1 ");
        if(isNotEmpty(query.getId())) {
            sql2.append(" and  t.id = :id ");
        }
        if(isNotEmpty(query.getStuNo1())) {
            sql2.append(" and  t.stuNo1 = :stuNo1 ");
        }
        if(isNotEmpty(query.getStuName2())) {
            sql2.append(" and  t.stuName2 = :stuName2 ");
        }
        if(isNotEmpty(query.getStuSex3())) {
            sql2.append(" and  t.stuSex3 = :stuSex3 ");
        }
        if(isNotEmpty(query.getStuZy4())) {
            sql2.append(" and  t.stuZy4 = :stuZy4 ");
        }
        if(isNotEmpty(query.getStuClasses5())) {
            sql2.append(" and  t.stuClasses5 = :stuClasses5 ");
        }
        if(isNotEmpty(query.getStuXi6())) {
            sql2.append(" and  t.stuXi6 = :stuXi6 ");
        }
        if(isNotEmpty(query.getStuIdcard7())) {
            sql2.append(" and  t.stuIdcard7 = :stuIdcard7 ");
        }
        if(isNotEmpty(query.getStuMobilePhone8())) {
            sql2.append(" and  t.stuMobilePhone8 = :stuMobilePhone8 ");
        }
        if(isNotEmpty(query.getStuEmail9())) {
            sql2.append(" and  t.stuEmail9 = :stuEmail9 ");
        }
        if(isNotEmpty(query.getStuSpeciality10())) {
            sql2.append(" and  t.stuSpeciality10 = :stuSpeciality10 ");
        }
        if(isNotEmpty(query.getStuAwards11())) {
            sql2.append(" and  t.stuAwards11 = :stuAwards11 ");
        }
        if(isNotEmpty(query.getStuPassword12())) {
            sql2.append(" and  t.stuPassword12 = :stuPassword12 ");
        }
        if(isNotEmpty(query.getStuRemark13())) {
            sql2.append(" and  t.stuRemark13 = :stuRemark13 ");
        }
        if(isNotEmpty(query.getStuStatue14())) {
            sql2.append(" and  t.stuStatue14 = :stuStatue14 ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	
	public StuBaseInfo getByStuNo1(java.lang.String v) {
		return (StuBaseInfo) findByProperty("stuNo1",v);
	}	

}
